Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create SecurityMonitorFacet and add associated mock and tests #954

Conversation

GregDixonMXN
Copy link

Resolves #927

Copy link
Member

@rndquu rndquu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall:

  1. The contract should be refactored from a Diamond facet to a "plain" simple contract
  2. Log based upkeeps should be used
  3. The solution should be fully QAed

@@ -14,6 +14,7 @@
"url": "https://github.com/ubiquity/ubiquity-dollar.git"
},
"dependencies": {
"@chainlink/contracts": "^1.2.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this package used anywhere? If not then it should be removed, chainlink contracts are already added as a github submodule here.

import "../../../src/dollar/interfaces/IUbiquityDollarToken.sol";
import "../../../src/dollar/interfaces/ITelegramNotifier.sol";

contract SecurityMonitorFacet is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security monitor contract should not be a part of the diamond (i.e. a separate facet). We'd keep things simple and have a separate SecurityMonitor contract which we'd deploy manually.

}

function checkUpkeep(
bytes calldata /* checkData */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to use log based upkeeps? Then we can catch transactions that look malicious right when they occur instead of relying on a perfect timing.


// Pause the UbiquityDollarToken and UbiquityPoolFacet

if (LibAccessControl.hasRole(PAUSER_ROLE, address(this))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check in unnecessary since we'll grant the PAUSER role to the security contract.


// that should work regardless of how pausing is implemented in UbiquityDollarToken

(bool success, ) = address(LibDiamond.contractOwner()).call(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try that it works as expected? Contract owner is an EOA so I don't fully understand how we can call the pauseDollarToken() method on it.

// that should work regardless of how pausing is implemented in UbiquityDollarToken

(bool success, ) = address(LibDiamond.contractOwner()).call(
abi.encodeWithSignature("pauseDollarToken()")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no such method pauseDollarToken() in the UbiquityDollarToken contract.


emit SecurityIncident(message);

ITelegramNotifier(LibDiamond.contractOwner()).notify(message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this line. I actually thought that services like https://defender.openzeppelin.com/ has a feature of sending telegram messages that can be set up in a few clicks. Why do we need the ITelegramNotifier interface and how is it supposed to work?

@GregDixonMXN GregDixonMXN closed this by deleting the head repository Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Security monitoring
2 participants